import { Viewer, Cartesian3, Color } from 'cesium'
import { ref } from 'vue'

const viewer = ref()

export const initView = (dom) => {
  viewer.value = new Viewer(dom)

  viewer.value.scene.debugShowFramesPerSecond = true;

  return viewer.value
}

export const addBox = (viewer, boxConfig) => {
  const box = viewer.entities.add({
    name: 'Red',
    position: Cartesian3.fromDegrees(-107.0, 40.0, 300000.0),
    box : {
      dimensions : new Cartesian3(400000.0, 300000.0, 500000.0),
      material : Color.RED.withAlpha(0.5),
      outline : true,
      outlineColor : Color.BLACK
    }
  })
  return box
}

export const getViewer = () => {
  return viewer.value
}